﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_RptBangKeThietBiSuaChua : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CboTinhTrang")]
        private ComboBox _CboTinhTrang;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("CmdOK")]
        private Button _CmdOK;
        [AccessedThroughProperty("GroupBox1")]
        private GroupBox _GroupBox1;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label13")]
        private Label _Label13;
        [AccessedThroughProperty("Label3")]
        private Label _Label3;
        [AccessedThroughProperty("TxtDenNgay")]
        private DateTimePicker _TxtDenNgay;
        [AccessedThroughProperty("TxtTuNgay")]
        private DateTimePicker _TxtTuNgay;
        private IContainer components;
        private bool mAllowAdd;
        private bool mAllowDel;
        private bool mAllowEdit;
        private bool mAllowView;
        private clsSuaChuaThietBi objTN;

        public Frm_RptBangKeThietBiSuaChua()
        {
            base.Load += new EventHandler(this.Frm_RptBangKeThietBiSuaChua_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.objTN = new clsSuaChuaThietBi();
            this.InitializeComponent();
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            this.PrintReport();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && (this.components != null))
                {
                    this.components.Dispose();
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }

        private void Frm_RptBangKeThietBiSuaChua_Load(object sender, EventArgs e)
        {
            LVYModule.GetUserRight(ref this.mAllowView, ref this.mAllowDel, ref this.mAllowEdit, ref this.mAllowAdd, Conversions.ToString(this.Tag), modGeneral.H_USERNAME);
            if (!this.mAllowView)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn kh\x00f4ng c\x00f3 quyền xem, li\x00ean hệ với người quản trị để biết th\x00eam chi tiết.", ""));
                this.Dispose();
            }
            else
            {
                this.TxtTuNgay.Text = "01/" + LVYModule.sRight("00" + Conversions.ToString(DateAndTime.Month(DateAndTime.Today)), 2) + "/" + Conversions.ToString(DateAndTime.Year(DateAndTime.Today));
                this.CboTinhTrang.Items.Clear();
                this.CboTinhTrang.Items.Add(modGeneral.Tranlated("Tất cả", ""));
                this.CboTinhTrang.Items.Add(modGeneral.Tranlated("Đang sửa chữa", ""));
                this.CboTinhTrang.Items.Add(modGeneral.Tranlated("Đ\x00e3 b\x00e0n giao cho kh\x00e1ch", ""));
                this.CboTinhTrang.SelectedIndex = 0;
            }
        }

        public DataTable GetDataPrint(string strCondition = "")
        {
            string commandText = "";
            string str2 = "";
            if (strCondition.Trim() != "")
            {
                str2 = " WHERE 1 = 1 " + strCondition;
            }
            commandText = " SELECT TN.Khoa, TN.SoChungTu, dbo.Char2Date(TN.NgayChungTu) As Ngay, HH.Ma as MaThietBi, HH.TenViet As TenThietBi, TN.SoSerial, KH.TenViet As KhachHang,  TN.TinhTrangThietBi as TinhTrangBanDau, TN.LoaiSuaChua,  TN.XacDinhLoi, TN.NguyenNhan, TN.DienGiai As ThongTinXuLy, dbo.Char2Date(TN.NgayTraHang) As NgayTraHang, TN.TrangThai FROM SC_tiepNhanThietBi TN  LEFT JOIN DM_HangHoa HH ON TN.KhoaHangHoa = HH.Khoa  LEFT JOIN DM_DoiTuong KH ON TN.KhoaDoiTuong = KH.Khoa " + str2;
            return DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_RptBangKeThietBiSuaChua));
            this.GroupBox1 = new GroupBox();
            this.CboTinhTrang = new ComboBox();
            this.Label3 = new Label();
            this.TxtDenNgay = new DateTimePicker();
            this.Label13 = new Label();
            this.TxtTuNgay = new DateTimePicker();
            this.Label1 = new Label();
            this.CmdCancel = new Button();
            this.CmdOK = new Button();
            this.GroupBox1.SuspendLayout();
            this.SuspendLayout();
            this.GroupBox1.Controls.Add(this.CboTinhTrang);
            this.GroupBox1.Controls.Add(this.Label3);
            this.GroupBox1.Controls.Add(this.TxtDenNgay);
            this.GroupBox1.Controls.Add(this.Label13);
            this.GroupBox1.Controls.Add(this.TxtTuNgay);
            this.GroupBox1.Controls.Add(this.Label1);
            Point point = new Point(12, 11);
            this.GroupBox1.Location = point;
            this.GroupBox1.Name = "GroupBox1";
            Size size = new Size(0x19d, 110);
            this.GroupBox1.Size = size;
            this.GroupBox1.TabIndex = 7;
            this.GroupBox1.TabStop = false;
            this.GroupBox1.Text = "T\x00f9y chọn";
            this.CboTinhTrang.FormattingEnabled = true;
            point = new Point(0x74, 0x1c);
            this.CboTinhTrang.Location = point;
            this.CboTinhTrang.Name = "CboTinhTrang";
            size = new Size(0x10f, 0x15);
            this.CboTinhTrang.Size = size;
            this.CboTinhTrang.TabIndex = 0x2c;
            this.Label3.AutoSize = true;
            point = new Point(220, 60);
            this.Label3.Location = point;
            this.Label3.Name = "Label3";
            size = new Size(0x35, 13);
            this.Label3.Size = size;
            this.Label3.TabIndex = 0x2b;
            this.Label3.Text = "Đến ng\x00e0y";
            this.TxtDenNgay.Format = DateTimePickerFormat.Short;
            point = new Point(300, 0x38);
            this.TxtDenNgay.Location = point;
            this.TxtDenNgay.Name = "TxtDenNgay";
            size = new Size(0x57, 20);
            this.TxtDenNgay.Size = size;
            this.TxtDenNgay.TabIndex = 2;
            this.Label13.AutoSize = true;
            point = new Point(0x12, 0x3b);
            this.Label13.Location = point;
            this.Label13.Name = "Label13";
            size = new Size(0x2e, 13);
            this.Label13.Size = size;
            this.Label13.TabIndex = 40;
            this.Label13.Text = "Từ ng\x00e0y";
            this.TxtTuNgay.Format = DateTimePickerFormat.Short;
            point = new Point(0x74, 0x38);
            this.TxtTuNgay.Location = point;
            this.TxtTuNgay.Name = "TxtTuNgay";
            size = new Size(0x57, 20);
            this.TxtTuNgay.Size = size;
            this.TxtTuNgay.TabIndex = 1;
            this.Label1.AutoSize = true;
            point = new Point(0x12, 0x1f);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x26, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 1;
            this.Label1.Text = "Đơn vị";
            this.CmdCancel.DialogResult = DialogResult.Cancel;
            this.CmdCancel.Image = (Image) manager.GetObject("CmdCancel.Image");
            this.CmdCancel.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x15a, 0x7f);
            this.CmdCancel.Location = point;
            this.CmdCancel.Name = "CmdCancel";
            size = new Size(0x4f, 0x18);
            this.CmdCancel.Size = size;
            this.CmdCancel.TabIndex = 9;
            this.CmdCancel.Text = "&Tho\x00e1t";
            this.CmdCancel.UseVisualStyleBackColor = true;
            this.CmdOK.Image = (Image) manager.GetObject("CmdOK.Image");
            this.CmdOK.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x107, 0x7f);
            this.CmdOK.Location = point;
            this.CmdOK.Name = "CmdOK";
            size = new Size(0x4e, 0x18);
            this.CmdOK.Size = size;
            this.CmdOK.TabIndex = 8;
            this.CmdOK.Text = "&Chọn";
            this.CmdOK.UseVisualStyleBackColor = true;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            size = new Size(0x1b2, 0x9e);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.GroupBox1);
            this.Controls.Add(this.CmdCancel);
            this.Controls.Add(this.CmdOK);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Frm_RptBangKeThietBiSuaChua";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Tag = "SC-BC01";
            this.Text = "BANG KE THIET BI SUA CHUA";
            this.GroupBox1.ResumeLayout(false);
            this.GroupBox1.PerformLayout();
            this.ResumeLayout(false);
        }

        public void PrintReport()
        {
            if (Form.ActiveForm != null)
            {
                Form.ActiveForm.Cursor = Cursors.WaitCursor;
            }
            string strCondition = " AND (TN.NgayChungTu BETWEEN '" + this.TxtTuNgay.Text + "' And '" + this.TxtDenNgay.Text + "')";
            if (this.CboTinhTrang.SelectedIndex == 1)
            {
                strCondition = strCondition + " AND RTRIM(TN.NgayTraHang) = ''";
            }
            if (this.CboTinhTrang.SelectedIndex == 2)
            {
                strCondition = strCondition + " AND RTRIM(TN.NgayTraHang) <> ''";
            }
            DataTable dataPrint = this.GetDataPrint(strCondition);
            if (dataPrint != null)
            {
                if (dataPrint.Rows.Count == 0)
                {
                    LVYModule.ShowWarning(modGeneral.Tranlated("Kh\x00f4ng c\x00f3 dữ liệu !", ""));
                }
                else
                {
                    Rpt_BangKeThietBiSuaChua chua = new Rpt_BangKeThietBiSuaChua();
                    try
                    {
                        chua.SetDataSource(dataPrint);
                        if (modGeneral.H_LANGUAGE == "VIET")
                        {
                            chua.SetParameterValue(0, modGeneral.Tranlated(modGeneral.H_COMPANYNAMEVIET, ""));
                        }
                        else
                        {
                            chua.SetParameterValue(0, modGeneral.Tranlated(modGeneral.H_COMPANYNAMEANH, ""));
                        }
                        chua.SetParameterValue(1, modGeneral.Tranlated("Địa chỉ", "") + ": " + modGeneral.H_ADDRESS);
                        chua.SetParameterValue(2, modGeneral.Tranlated("M\x00e3 số thuế", "") + ": " + modGeneral.H_TAXCODE);
                        chua.SetParameterValue(3, modGeneral.Tranlated("Điện thoại", "") + ": " + modGeneral.H_TELEPHONE);
                        chua.SetParameterValue(4, modGeneral.Tranlated("Fax", "") + ": " + modGeneral.H_FAX);
                        chua.SetParameterValue(5, modGeneral.Tranlated("Hotline", "") + ": " + modGeneral.H_HOTLINE);
                        chua.SetParameterValue(6, modGeneral.Tranlated("Từ ng\x00e0y", "") + ": " + this.TxtTuNgay.Text + " " + modGeneral.Tranlated("đến ng\x00e0y", "") + ": " + this.TxtDenNgay.Text);
                        MyProject.Forms.Frm_ViewReport.ReportViewer.ReportSource = chua;
                        MyProject.Forms.Frm_ViewReport.ReportViewer.DisplayGroupTree = false;
                        MyProject.Forms.Frm_ViewReport.ShowDialog();
                        if (Form.ActiveForm != null)
                        {
                            Form.ActiveForm.Cursor = Cursors.Default;
                        }
                    }
                    catch (Exception exception1)
                    {
                        ProjectData.SetProjectError(exception1);
                        Exception exception = exception1;
                        if (Form.ActiveForm != null)
                        {
                            Form.ActiveForm.Cursor = Cursors.Default;
                        }
                        MessageBox.Show(exception.Message.ToString());
                        ProjectData.ClearProjectError();
                    }
                }
            }
        }

        internal virtual ComboBox CboTinhTrang
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboTinhTrang;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CboTinhTrang = value;
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CmdCancel = value;
            }
        }

        internal virtual Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        internal virtual GroupBox GroupBox1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._GroupBox1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._GroupBox1 = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label13
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label13;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label13 = value;
            }
        }

        internal virtual Label Label3
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label3;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label3 = value;
            }
        }

        internal virtual DateTimePicker TxtDenNgay
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtDenNgay;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtDenNgay = value;
            }
        }

        internal virtual DateTimePicker TxtTuNgay
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtTuNgay;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtTuNgay = value;
            }
        }
    }
}

